<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\JjrUser */

$this->title = $model->real_name;
$this->params['breadcrumbs'][] = ['label' => 'Jjr Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="jjr-user-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'openid',
            'mobile',
            'real_name',
            ['attribute'=>'gender','value'=>function($model){
                if($model->gender==1){
                    return '男';
                }else if($model->gender==2){
                    return '女';
                }

            }],
            ['attribute'=>'identity','value'=>function($model){
                if($model->identity==1){
                    return '自由经纪人';
                }else if($model->identity==2){
                    return '公司经纪人';
                }

            }],
            'create_time',
            'update_time',
            [
                'attribute' => 'status',
                'value' => function($model) {//使用匿名函数格式化（参数为当前模型对象），也可以在模型类中定义该方法
                    $status = ['未审核', '已审核','未知'];
                    return $status[$model->status];
                }
            ],

        ],
    ]) ?>

</div>


<!-- 定义数据块 -->
<?php $this->beginBlock('test'); ?>
jQuery(document).ready(function() {
highlight_subnav('jjr-user/index'); //子导航高亮
});
<?php $this->endBlock() ?>
<!-- 将数据块 注入到视图中的某个位置 -->
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>
